class_name ControllerBase
extends Resource

var is_registered:bool = false
signal key_action_state_changed(key_action:GameEnum.KeyAction,key_action_state:GameEnum.KeyActionState)

## 虚函数
## 注册绑定KeyAction的事件
func register_key_action_event(callable:Callable):
	is_registered = true
	if not key_action_state_changed.is_connected(callable):
		key_action_state_changed.connect(callable)
## 虚函数
## 取消注册绑定KeyAction的事件
func unregister_key_action_event(callable:Callable):
	is_registered = false
	if key_action_state_changed.is_connected(callable):
		key_action_state_changed.disconnect(callable)
## 手动发出KeyAction的事件
func send_key_action_event(key_action:GameEnum.KeyAction,key_action_state:GameEnum.KeyActionState):
	key_action_state_changed.emit(key_action,key_action_state)
## 重置指定KeyAction
func reset_key_action(key_action:GameEnum.KeyAction):
	send_key_action_event(key_action,GameEnum.KeyActionState.Idle)
## 重置所有KeyAction
func reset_all_key_action():
	for key_action in GameEnum.KeyAction.values():
		reset_key_action(key_action)
## 轮询检查KeyAction的事件
func check_process() -> bool:
	if not is_registered:
		return false
	return true
